package org.shopen.puremvc.controller.testing
{
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	import org.puremvc.as3.utilities.statemachine.StateMachine;
	import org.shopen.puremvc.ApplicationConstants;
	import org.shopen.puremvc.model.TestingProxy;
	import org.shopen.puremvc.model.domain.testing.Testing;

	public class SelectTestingCommand extends SimpleCommand
	{
		override public function execute(notification:INotification):void
		{
			try
			{
				var testing : Testing = notification.getBody() as Testing;
				var testingProxy : TestingProxy = facade.retrieveProxy(TestingProxy.NAME) as TestingProxy;
				if (testing != null)
				{
					testingProxy.currentTesting = testing.clone();
				}
				sendNotification(StateMachine.ACTION, null, ApplicationConstants.ACTION_START_TESTING);
			}
			catch (error : Error)
			{
				sendNotification(ApplicationConstants.GENERAL_ERROR, error);
			}
		}
	}
}